
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

/**
 *Clase que crea la estructura de menus de la pantalla principal
 * @author Matías Díaz
 * @author Sergio Flores
 */
public class MenuStructure
{

    private static HashMap<MenuObject , List<MenuObject>> structure;
    private static List<MenuObject> menus;

    static
    {
        MenuObject separator = new MenuObject ();
        separator.setSeparator ( true );

        MenuStructure.structure = new HashMap<> ();
        //----------------------- JUEGO-----------------------------------------
        MenuObject juego = new MenuObject ( CommandName.JUEGO , KeyEvent.VK_J );
        List<MenuObject> itemsJuego = new ArrayList<> ();
        itemsJuego.add ( new MenuObject ( CommandName.NUEVO , KeyEvent.VK_N , KeyStroke.getKeyStroke ( KeyEvent.VK_N , ActionEvent.CTRL_MASK ) ) );
        itemsJuego.add ( separator );
        itemsJuego.add ( new MenuObject ( CommandName.SALIR , KeyEvent.VK_S , KeyStroke.getKeyStroke ( KeyEvent.VK_F4 , ActionEvent.ALT_MASK ) ) );
        MenuStructure.structure.put ( juego , itemsJuego );

        //------------------------VER-------------------------------------------
        MenuObject ver = new MenuObject ( CommandName.VER , KeyEvent.VK_V );
        List<MenuObject> itemsVer = new ArrayList<> ();
        itemsVer.add ( new MenuObject ( CommandName.SOLUCION , KeyEvent.VK_O , KeyStroke.getKeyStroke ( KeyEvent.VK_R , ActionEvent.CTRL_MASK ) ) );
        itemsVer.add ( separator );
        itemsVer.add ( new MenuObject ( CommandName.PUNTAJE , KeyEvent.VK_P , KeyStroke.getKeyStroke ( KeyEvent.VK_P , ActionEvent.CTRL_MASK ) ) );
        MenuStructure.structure.put ( ver , itemsVer );

        //-----------------------BACKGROUND-------------------------------------
        MenuObject fondo = new MenuObject ( CommandName.FONDO , KeyEvent.VK_F );
        List<MenuObject> itemsFondo = new ArrayList<> ();
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_RED , KeyEvent.VK_R , KeyStroke.getKeyStroke ( KeyEvent.VK_R , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_BLACK , KeyEvent.VK_N , KeyStroke.getKeyStroke ( KeyEvent.VK_N , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_GREEN , KeyEvent.VK_V , KeyStroke.getKeyStroke ( KeyEvent.VK_V , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_BLUE , KeyEvent.VK_A , KeyStroke.getKeyStroke ( KeyEvent.VK_A , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_YELLOW , KeyEvent.VK_I , KeyStroke.getKeyStroke ( KeyEvent.VK_I , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_GRAY , KeyEvent.VK_G , KeyStroke.getKeyStroke ( KeyEvent.VK_G , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_MAGENTA , KeyEvent.VK_M , KeyStroke.getKeyStroke ( KeyEvent.VK_M , ActionEvent.ALT_MASK ) ) );
        itemsFondo.add ( new MenuObject ( CommandName.COLOR_CYAN , KeyEvent.VK_C , KeyStroke.getKeyStroke ( KeyEvent.VK_C , ActionEvent.ALT_MASK ) ) );
        MenuStructure.structure.put ( fondo , itemsFondo );

        //--------------------------TAMANO--------------------------------------
        MenuObject tamano = new MenuObject ( CommandName.TAMANO , KeyEvent.VK_T );
        List<MenuObject> itemsTamano = new ArrayList<> ();
        itemsTamano.add ( new MenuObject ( CommandName.DOS_DOS , KeyEvent.VK_2 , KeyStroke.getKeyStroke ( KeyEvent.VK_2 , ActionEvent.CTRL_MASK ) ) );
        itemsTamano.add ( new MenuObject ( CommandName.TRES_TRES , KeyEvent.VK_3 , KeyStroke.getKeyStroke ( KeyEvent.VK_3 , ActionEvent.CTRL_MASK ) ) );
        itemsTamano.add ( new MenuObject ( CommandName.CUATRO_CUATRO , KeyEvent.VK_4 , KeyStroke.getKeyStroke ( KeyEvent.VK_4 , ActionEvent.CTRL_MASK ) ) );
        itemsTamano.add ( new MenuObject ( CommandName.CINCO_CINCO , KeyEvent.VK_5 , KeyStroke.getKeyStroke ( KeyEvent.VK_5 , ActionEvent.CTRL_MASK ) ) );
        itemsTamano.add ( new MenuObject ( CommandName.SEIS_SEIS , KeyEvent.VK_6 , KeyStroke.getKeyStroke ( KeyEvent.VK_6 , ActionEvent.CTRL_MASK ) ) );
        MenuStructure.structure.put ( tamano , itemsTamano );

        //----------------------------AYUDA-------------------------------------
        MenuObject ayuda = new MenuObject ( CommandName.AYUDA , KeyEvent.VK_U );
        List<MenuObject> itemsAyuda = new ArrayList<> ();
        itemsAyuda.add ( new MenuObject ( CommandName.AYUDA , KeyEvent.VK_U ) );
        itemsAyuda.add ( new MenuObject ( CommandName.ACERCA_DE , KeyEvent.VK_A ) );
        MenuStructure.structure.put ( ayuda , itemsAyuda );

        //----------------------------------------------------------------------
        //----------------------------------------------------------------------
        MenuStructure.menus = new ArrayList<> ();
        MenuStructure.menus.add ( juego );
        MenuStructure.menus.add ( ver );
        MenuStructure.menus.add ( tamano );
        MenuStructure.menus.add ( fondo );
        MenuStructure.menus.add ( ayuda );

    }

    /**
     * Metodo que retorna la lista con los menus.
     * @return lista de menus.
     */
    static public List<MenuObject> getMenus ()
    {
        return MenuStructure.menus;
    }

    /**
     * Metodo que retorna la lista de menus segun un menu especifico.
     * @param menu que se utilizara.
     * @return lista con los items de ese menu.
     */
    static public List<MenuObject> getMenuItems ( MenuObject menu )
    {
        return MenuStructure.structure.get ( menu );
    }
}
